<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item :label="$t('订单号')">
              <a-input :placeholder="$t('请输入订单号')" v-model="queryParam.orderId"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="10" :lg="11" :md="12" :sm="24">
            <a-form-item :label="$t('g_购买时间')">
              <j-date
                :show-time="{ defaultValue: moment('00:00:00', 'HH:mm:ss') }"
                valueFormat="YYYY-MM-DD HH:mm:ss"
                dateFormat="YYYY-MM-DD HH:mm:ss"
                :placeholder="$t('请选择开始时间')"
                class="query-group-cust"
                v-model="queryParam.buyTime_begin"
              ></j-date>
              <span class="query-group-split-cust"></span>
              <j-date
                :show-time="{ defaultValue: moment('23:59:59', 'HH:mm:ss') }"
                valueFormat="YYYY-MM-DD HH:mm:ss"
                dateFormat="YYYY-MM-DD HH:mm:ss"
                :placeholder="$t('请选择结束时间')"
                class="query-group-cust"
                v-model="queryParam.buyTime_end"
              ></j-date>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">{{ $t('查询') }}</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">{{
                $t('重置')
              }}</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? $t('收起') : $t('展开') }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
              <a-button
                v-has="'BisOrderGoodsController:export'"
                type="primary"
                icon="download"
                :loading="exloading"
                @click="handleExportXls($t('商品销售明细'))"
                style="margin-left: 8px"
                >{{ $t('导出') }}</a-button
              >
            </span>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item :label="$t('商品')">
                <a-input :placeholder="$t('请输入商品编码/名称')" v-model="queryParam.goodsInfo"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item :label="$t('商品形态')">
                <a-select v-model="queryParam.form" :placeholder="$t('请选择商品形态')">
                  <a-select-option v-for="item in formlist" :key="item.value" :value="item.value">{{
                    item.title
                  }}</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item :label="$t('商品分类')">
                <a-tree-select
                  allowClear
                  v-model="queryParam.goodsKindId"
                  :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
                  :tree-data="treeData"
                  :search-placeholder="$t('请选择')"
                />
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item :label="$t('订单类型')">
                <a-select v-model="queryParam.orderType">
                  <a-select-option value="0,2,4,8,6,10,11">{{ $t('全部') }}</a-select-option>
                  <a-select-option value="0">{{ $t('销售订单') }}</a-select-option>
                  <a-select-option value="2">{{ $t('销售退单') }}</a-select-option>
                  <a-select-option value="4">{{ $t('美团核销') }}</a-select-option>
                  <a-select-option value="8">{{ $t('抖音核销') }}</a-select-option>
                  <a-select-option value="11">{{ $t('快手核销') }}</a-select-option>
                  <a-select-option value="6">{{ $t('会员退币') }}</a-select-option>
                  <a-select-option value="10">{{ $t('会员退票') }}</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item :label="$t('赠送商品')">
                <a-select v-model="queryParam.isGift">
                  <a-select-option value="">{{ $t('全部') }}</a-select-option>
                  <a-select-option value="1">{{ $t('是') }}</a-select-option>
                  <a-select-option value="0">{{ $t('否') }}</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item>
                <a-checkbox v-model="queryParam.isChildState">{{ $t('不显示套餐子商品') }}</a-checkbox>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24" v-if="!tenantid">
              <a-form-item :label="$t('门店')">
                <a-select v-model="queryParam.shopCode">
                  <a-select-option v-for="(item, i) in shops" :key="i" :value="item.value"
                    >{{ item.title }}<span v-if="item.value != ''">（{{ item.value }}）</span></a-select-option
                  >
                </a-select>
              </a-form-item>
            </a-col>
          </template>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :scroll="{ x: true, y: tableHeight }"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :customHeaderRow="customHeaderRow"
        :customRow="customRow"
        @change="handleTableChange"
      >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无图片') }}</span>
          <img
            v-else
            :src="getImgView(text)"
            height="25px"
            alt
            style="max-width: 80px; font-size: 12px; font-style: italic"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无文件') }}</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">{{
            $t('下载')
          }}</a-button>
        </template>
        <span slot="action" slot-scope="text, record">
          <a-dropdown>
            <a class="ant-dropdown-link">
              {{ $t('更多') }}
              <a-icon type="down" />
            </a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">{{ $t('详情') }}</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm :title="$t('确定删除吗?')" @confirm="() => handleDelete(record.id)">
                  <a>{{ $t('删除') }}</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
        <template slot="footer">
          <div style="font-weight: bold">
            <span style="margin-left: 15px; margin-right: 5px">{{ $t('数量') }}：</span>
            <span>{{ totalInfo.amount ? totalInfo.amount.toFixed(0) : 0 }}</span>
            <span style="margin-left: 15px; margin-right: 5px">{{ $t('原价') }}：</span>
            <span>{{ totalInfo.totle ? totalInfo.totle.toFixed(2) : '0.00' }}</span>
            <span style="margin-left: 15px; margin-right: 5px">{{ $t('会员优惠') }}：</span>
            <span>{{ totalInfo.memberDiscount ? totalInfo.memberDiscount.toFixed(2) : '0.00' }}</span>
            <span style="margin-left: 15px; margin-right: 5px">{{ $t('活动优惠') }}：</span>
            <span>{{ totalInfo.activityDiscount ? totalInfo.activityDiscount.toFixed(2) : '0.00' }}</span>
            <span style="margin-left: 15px; margin-right: 5px">{{ $t('优惠券抵扣') }}：</span>
            <span>{{ totalInfo.couponDiscount ? totalInfo.couponDiscount.toFixed(2) : '0.00' }}</span>
            <span style="margin-left: 15px; margin-right: 5px" v-if="isTax != 0">{{ $t('其中税费') }}：</span>
            <span v-if="isTax != 0">{{ totalInfo.payAmount ? totalInfo.taxPrice.toFixed(2) : '0.00' }}</span>
            <span style="margin-left: 15px; margin-right: 5px">{{ $t('实付金额') }}：</span>
            <span>{{ totalInfo.payAmount ? totalInfo.payAmount.toFixed(2) : '0.00' }}</span>
          </div>
        </template>
      </a-table>
    </div>
    <goods-sales-modal ref="modalForm" @ok="modalFormOk"></goods-sales-modal>
  </a-card>
</template>

<script>
import Vue from 'vue'
import moment from 'moment'
import '@/assets/less/TableExpand.less'
import { getAction, downFile } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { initDictOptions, filterMultiDictText } from '@/components/dict/JDictSelectUtil'
import GoodsSalesModal from './modules/GoodsSalesModal'

export default {
  name: 'GoodsSalesList',
  mixins: [JeecgListMixin],
  components: {
    GoodsSalesModal,
  },
  data() {
    return {
      description: '商品销售管理页面',
      moment,
      tenantid: Vue.ls.get('TENANT_ID'),
      // 表头
      columns: [
        {
          title: this.$t('订单号'),
          align: 'center',
          dataIndex: 'orderId',
          width: 164,
        },
        {
          title: this.$t('g_购买时间'),
          align: 'center',
          dataIndex: 'buyTime',
          width: 160,
        },
        {
          title: this.$t('订单类型'),
          align: 'center',
          dataIndex: 'orderType_dictText',
          width: 150,
          customCell: (r, i) => {
            return {
              style: {
                whiteSpace: 'normal',
              },
            }
          },
        },
        {
            title: this.$t('商品编码'),
            align: 'center',
            dataIndex: 'goodsCode',
            width: 100,
            customCell: (r, i) => {
              return {
                style: {
                  whiteSpace: 'normal',
                },
              }
            },
          },
        {
          title: this.$t('商品名称'),
          align: 'center',
          dataIndex: 'goodsName',
          width: 260,
          customCell: (r, i) => {
            return {
              style: {
                whiteSpace: 'normal',
              },
            }
          },
        },
        {
          title: this.$t('商品形态'),
          align: 'center',
          dataIndex: 'form_dictText',
          width: 96,
          customCell: (r, i) => {
            return {
              style: {
                whiteSpace: 'normal',
              },
            }
          },
        },
        {
          title: this.$t('商品分类'),
          align: 'center',
          dataIndex: 'goodsKindName',
          width: 100,
          customCell: (r, i) => {
            return {
              style: {
                whiteSpace: 'normal',
              },
            }
          },
        },
        {
          title: this.$t('成本单价'),
          align: 'center',
          dataIndex: 'cost',
          width: 90,
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customRender: (text, r) => {
            return text.toFixed(2);
          }
        },
        {
          title: this.$t('g_销售单价'),
          align: 'center',
          dataIndex: 'price',
          width: 100,
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customRender: (text, r) => {
            return text.toFixed(2);
          }
        },
        {
          title: this.$t('数量'),
          align: 'center',
          dataIndex: 'amount',
          width: 80,
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customRender: (text, r) => {
            return text.toFixed(0);
          }
        },
        {
          title: this.$t('原价'),
          align: 'center',
          dataIndex: 'totle',
          width: 110,
          customCell: (r, i) => {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
          customRender: (text, r) => {
            return text.toFixed(2);
          }
        },
        {
          title: this.$t('会员优惠'),
          align: 'center',
          dataIndex: 'memberDiscount',
          customRender: function (text, record) {
            return text.toFixed(2)
          },
          width: 160,
          customCell: (r, i) => {
            return {
              style: {
                whiteSpace: 'normal',
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('活动优惠'),
          align: 'center',
          dataIndex: 'activityDiscount',
          customRender: function (text, record) {
            return text.toFixed(2)
          },
          width: 160,
          customCell: (r, i) => {
            return {
              style: {
                whiteSpace: 'normal',
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('优惠券抵扣'),
          align: 'center',
          dataIndex: 'couponDiscount',
          customRender: function (text, record) {
            return text.toFixed(2)
          },
          width: 160,
          customCell: (r, i) => {
            return {
              style: {
                whiteSpace: 'normal',
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('实付金额'),
          align: 'center',
          dataIndex: 'payAmount',
          width: 100,
          customRender: function (text, record) {
            return text.toFixed(2)
          },
          customCell: function () {
            return {
              style: {
                textAlign: 'right',
              },
            }
          },
        },
        {
          title: this.$t('取货状态'),
          align: 'center',
          dataIndex: 'state_dictText',
          width: 100,
        },
        {
          title: this.$t('g_取货时间'),
          align: 'center',
          dataIndex: 'takeTime',
          width: 160,
        },
        {
          title: this.$t('已取数量'),
          align: 'right',
          dataIndex: 'takeNum',
          width: 100,
          customRender: (text, r) => {
            return text.toFixed(0);
          }
        },
        {
          title: this.$t('g_是否赠送'),
          align: 'center',
          dataIndex: 'isGift_dictText',
          width: 100,
        },
        {
          title: this.$t('是否子商品订单'),
          align: 'center',
          dataIndex: 'isChild_dictText',
          width: 120,
        },
        {
          title: this.$t('父商品订单'),
          align: 'center',
          dataIndex: 'parentId',
          width: 160,
        },
      ],
      url: {
        list: '/ordergoods/bisOrderGoods/list',
        delete: '/ordergoods/bisOrderGoods/delete',
        deleteBatch: '/ordergoods/bisOrderGoods/deleteBatch',
        exportXlsUrl: '/ordergoods/bisOrderGoods/exportXls',
        importExcelUrl: '/ordergoods/bisOrderGoods/importExcel',
        totalUrl: '/ordergoods/bisOrderGoods/total',
      },
      queryParam: {
        isGift: '',
        isChildState: false,
        valid: 1,
        orderType: '0,2,4,8,6,10,11',
        goodsKindId: '',
        shopCode: '',
      },
      isorter: {
        column: 'buyTime',
        order: 'desc',
      },
      treeData: [],
      allChildKind: [],
      isfooter: true,
      isCustom: true,
      isHideData: false,
      formlist: [],
      shops: [],
      hideCond: 2,
      isTax: localStorage.getItem('taxSetting'),
    }
  },
  created() {
    if (!this.tenantid) {
      let dtl = {
          title: this.$t('门店编码'),
          align: 'center',
          dataIndex: 'shopCode',
          width: 100,
          customCell: (r, i) => {
            return {
              style: {
                whiteSpace: 'normal',
              },
            }
          },
        },
        dtl1 = {
          title: this.$t('门店名称'),
          align: 'center',
          dataIndex: 'shopCode_dictText',
          width: 140,
          customCell: (r, i) => {
            return {
              style: {
                whiteSpace: 'normal',
              },
            }
          },
        }
      this.columns.unshift(dtl1)
      this.columns.unshift(dtl)
    } else {
      this.isTax = localStorage.getItem('taxSetting')
      if (this.isTax != 0) {
        this.columns.splice(14, 0, {
          title: this.$t('其中税费'),
          align: 'center',
          dataIndex: 'taxPrice',
          width: 96,
          customRender: (text, record) => {
            return record.taxPrice.toFixed(2)
          },
          customCell: (r, i) => {
            return {
              style: {
                whiteSpace: 'normal',
                textAlign: 'right',
              },
            }
          },
        })
      }
    }
    this.select()
  },
  mounted() {
    let that = this
    document.onkeydown = function (e) {
      let key = window.event.keyCode
      if (key == 75 && event.ctrlKey) {
        window.event.preventDefault()
        that.isHideData = false
        that.queryParam.dataType = 0
        that.searchQuery()
      }
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  watch: {
    $route: {
      handler: function (to, from) {
        this.columns = [
          {
            title: this.$t('订单号'),
            align: 'center',
            dataIndex: 'orderId',
            width: 164,
          },
          {
            title: this.$t('g_购买时间'),
            align: 'center',
            dataIndex: 'buyTime',
            width: 160,
          },
          {
            title: this.$t('订单类型'),
            align: 'center',
            dataIndex: 'orderType_dictText',
            width: 100,
            customCell: (r, i) => {
              return {
                style: {
                  whiteSpace: 'normal',
                },
              }
            },
          },
          {
            title: this.$t('商品编码'),
            align: 'center',
            dataIndex: 'goodsCode',
            width: 150,
            customCell: (r, i) => {
              return {
                style: {
                  whiteSpace: 'normal',
                },
              }
            },
          },
          {
            title: this.$t('商品名称'),
            align: 'center',
            dataIndex: 'goodsName',
            width: 260,
            customCell: (r, i) => {
              return {
                style: {
                  whiteSpace: 'normal',
                },
              }
            },
          },
          {
            title: this.$t('商品形态'),
            align: 'center',
            dataIndex: 'form_dictText',
            width: 96,
            customCell: (r, i) => {
              return {
                style: {
                  whiteSpace: 'normal',
                },
              }
            },
          },
          {
            title: this.$t('商品分类'),
            align: 'center',
            dataIndex: 'goodsKindName',
            width: 100,
            customCell: (r, i) => {
              return {
                style: {
                  whiteSpace: 'normal',
                },
              }
            },
          },
          {
            title: this.$t('成本单价'),
            align: 'center',
            dataIndex: 'cost',
            width: 90,
            customCell: (r, i) => {
              return {
                style: {
                  textAlign: 'right',
                },
              }
            },
          },
          {
            title: this.$t('g_销售单价'),
            align: 'center',
            dataIndex: 'price',
            width: 100,
            customCell: (r, i) => {
              return {
                style: {
                  textAlign: 'right',
                },
              }
            },
          },
          {
            title: this.$t('数量'),
            align: 'center',
            dataIndex: 'amount',
            width: 80,
            customCell: (r, i) => {
              return {
                style: {
                  textAlign: 'right',
                },
              }
            },
          },
          {
            title: this.$t('原价'),
            align: 'center',
            dataIndex: 'totle',
            width: 110,
            customCell: (r, i) => {
              return {
                style: {
                  textAlign: 'right',
                },
              }
            },
          },
          {
            title: this.$t('会员优惠'),
            align: 'center',
            dataIndex: 'memberDiscount',
            customRender: function (text, record) {
              return record.memberDiscount.toFixed(2)
            },
            width: 160,
            customCell: (r, i) => {
              return {
                style: {
                  whiteSpace: 'normal',
                  textAlign: 'right',
                },
              }
            },
          },
          {
            title: this.$t('活动优惠'),
            align: 'center',
            dataIndex: 'activityDiscount',
            customRender: function (text, record) {
              return record.activityDiscount.toFixed(2)
            },
            width: 160,
            customCell: (r, i) => {
              return {
                style: {
                  whiteSpace: 'normal',
                  textAlign: 'right',
                },
              }
            },
          },
          {
            title: this.$t('优惠券抵扣'),
            align: 'center',
            dataIndex: 'couponDiscount',
            customRender: function (text, record) {
              return record.couponDiscount.toFixed(2)
            },
            width: 160,
            customCell: (r, i) => {
              return {
                style: {
                  whiteSpace: 'normal',
                  textAlign: 'right',
                },
              }
            },
          },
          {
            title: this.$t('实付金额'),
            align: 'center',
            dataIndex: 'payAmount',
            width: 100,
            customRender: function (text, record) {
              return record.payAmount.toFixed(2)
            },
            customCell: function () {
              return {
                style: {
                  textAlign: 'right',
                },
              }
            },
          },
          {
            title: this.$t('取货状态'),
            align: 'center',
            dataIndex: 'state_dictText',
            width: 100,
          },
          {
            title: this.$t('g_取货时间'),
            align: 'center',
            dataIndex: 'takeTime',
            width: 160,
          },
          {
            title: this.$t('已取数量'),
            align: 'center',
            dataIndex: 'takeNum',
            width: 100,
          },
          {
            title: this.$t('g_是否赠送'),
            align: 'center',
            dataIndex: 'isGift_dictText',
            width: 100,
          },
          {
            title: this.$t('是否子商品订单'),
            align: 'center',
            dataIndex: 'isChild_dictText',
            width: 120,
          },
          {
            title: this.$t('父商品订单'),
            align: 'center',
            dataIndex: 'parentId',
            width: 160,
          },
        ]
        if (!this.tenantid) {
          let dtl = {
              title: this.$t('门店编码'),
              align: 'center',
              dataIndex: 'shopCode',
              width: 100,
              customCell: (r, i) => {
                return {
                  style: {
                    whiteSpace: 'normal',
                  },
                }
              },
            },
            dtl1 = {
              title: this.$t('门店名称'),
              align: 'center',
              dataIndex: 'shopCode_dictText',
              width: 140,
              customCell: (r, i) => {
                return {
                  style: {
                    whiteSpace: 'normal',
                  },
                }
              },
            }
          this.columns.unshift(dtl1)
          this.columns.unshift(dtl)
        } else {
          this.isTax = localStorage.getItem('taxSetting')
          if (this.isTax != 0) {
            this.columns.splice(14, 0, {
              title: this.$t('其中税费'),
              align: 'center',
              dataIndex: 'taxPrice',
              width: 96,
              customRender: (text, record) => {
                return record.taxPrice.toFixed(2)
              },
              customCell: (r, i) => {
                return {
                  style: {
                    whiteSpace: 'normal',
                    textAlign: 'right',
                  },
                }
              },
            })
          }
        }
      },
    },
  },
  methods: {
    initDictConfig() {
      this.customInit()
      initDictOptions('bis_goods_infor.form').then((res) => {
        if (res.success) {
          this.formlist = res.result
          this.formlist.unshift({ value: '', title: this.$t('全部') })
        }
      })
      initDictOptions('bis_shop,name,code').then((res) => {
        if (res.success) {
          this.shops = res.result
          this.shops.unshift({ value: '', title: this.$t('全部') })
        }
      })
    },
    customInit() {
      this.isHideData = true
      this.queryParam.dataType = 2
      this.searchQuery()
    },
    searchQuery() {
      this.selectedRowIndex = []
      if (this.queryParam.isChildState == true) {
        this.queryParam.isChild = '0'
      } else {
        this.queryParam.isChild = ''
      }
      this.loadData(1)
    },
    searchReset() {
      this.queryParam = {
        isGift: '',
        isChildState: false,
        valid: 1,
        orderType: '0,2,4,8,6,10,11',
        goodsKindId: '',
        shopCode: '',
      }
      this.selectedRowIndex = []
      this.customInit()
    },
    select() {
      let that = this
      let param = {}
      param.pageNo = 1
      param.pageSize = 9999
      param.column = 'sort'
      param.order = 'asc'
      getAction('/goods/bisGoodsKind/rootList', param)
        .then((res) => {
          if (res.success) {
            that.allChildKind = []
            if (res.result.records.length > 0) {
              res.result.records.forEach((col) => {
                col.key = '' + col.id
                col.value = '' + col.id
                col.title = '' + col.name
                col.id = '' + col.id
                col.pid = '' + col.pid
                col.hasChild = '' + col.hasChild
                if (col.hasChild != '0') {
                  that.getHasChild(col)
                }
              })
              that.treeData = that.getDataByResult(res.result.records)
              that.treeData.unshift({ key: '', id: '', value: '', title: this.$t('全部') })
            } else {
              that.treeData = []
            }
          } else {
            that.$alert(res.message, this.$t('提示'), {
              confirmButtonText: this.$t('确定'),
              callback: (action) => {},
            })
          }
        })
        .catch((error) => {
          console.log(error)
        })
    },
    getHasChild(record) {
      let that = this
      let query = {}
      query.pageNo = 1
      query.pageSize = 9999
      query.pid = record.id
      getAction('/goods/bisGoodsKind/rootList', query)
        .then((res) => {
          if (res.success) {
            if (res.result.records.length > 0) {
              res.result.records.forEach((col) => {
                col.key = '' + col.id
                col.value = '' + col.id
                col.title = '' + col.name
                col.pid = '' + col.pid
                col.id = '' + col.id
                col.hasChild = '' + col.hasChild
                if (col.hasChild != '0') {
                  that.getHasChild(col)
                }
              })
              record.children = that.getDataByResult(res.result.records)
              that.treeData = [...that.treeData]
            }
          } else {
            that.$message.warning(res.message)
          }
        })
        .catch((error) => {
          console.log(error)
        })
    },
    getDataByResult(result) {
      let that = this
      return result.map((item) => {
        if (item.hasChild == 0 && item.key != '0') {
          that.allChildKind.push(item.key)
        }
        return item
      })
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>